/*=============== THEN ADDS CENSUS DIVISION & TIME TREND ====================*/



* local  dem i.race##i.post2002 i.marst i.famsize i.nchild i.educ i.hispan##i.post2002 i.sex i.nchild##i.pre1988  i.race#i.pre1988
local  dem i.dem_race##i.post2002  i.dem_race#i.pre1988 i.dem_married i.dem_famsize ///
i.dem_nchild i.dem_nchild##i.pre1988 i.dem_educ i.dem_female i.dem_hisp##i.post2002

local rhs  age_* eitc_dube ur gdppc

local  a1 year i.state_fips `dem'
local  a2 year i.state_fips `dem' strecdums2
local  a3 year i.state_fips `dem' c.year##i.state_fips
local  a4 year i.state_fips `dem' i.year#i.division
local  a5 year i.state_fips `dem' c.year##i.state_fips i.year#i.division


local primary

local j .5
local thresholdlist 1 
local d 1
local j 1
local spec 3
foreach d of numlist 1 {
forvalues spec = 1/5 {
  foreach j of numlist `thresholdlist' {

  use "${data1}regready_cps_ipums_84.dta" , clear
  replace contpov = contpov_dube
  
  cap drop strecdums2
  cap drop recdums2
  recode year 2008=1 2009=2 2010=3 nonmissing=0, g(recdums2)
  egen strecdums2 = group(recdums2 state_fips)

  cap drop under


  gen under = contpov < `j'
  local q = `j' * 100
  di "Poverty threshold `q'"
  sum under if dem`d'==1
  reghdfe under lnMW `rhs'  [pw=asecwt] if dem`d'==1 , a(`a`spec'') cluster(state_fips)
  est save "${est}ster/84/MW1_`q'_dem`d'_s`spec'_spatial_var_dubecont", replace

  reghdfe under lnMWF1 lnMW lnMWL1 lnMWL2 lnMWL3 `rhs'  [pw=asecwt] if dem`d'==1 , a(`a`spec'') cluster(state_fips)
  est save "${est}ster/84/MW2_`q'_dem`d'_s`spec'_spatial_var_dubecont", replace
    * di `spec'
  }

  }


 
}
